<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta id="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
		<meta name="apple-themes-web-app-capable" content="yes">
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection">
		<meta content="email=no" name="format-detection">
		<meta name="format-detection" content="telephone=no">
		<title>在线冲流量</title>
		<link rel="stylesheet" href="${s.base}/mobile/css/main.css" type="text/css" media="all">
		<link rel="stylesheet" href="${s.base}/mobile/css/weui.min.css">
		<link rel="stylesheet" href="${s.base}/mobile/css/jquery-weui.min.css">
	</head>

	<body>
		<header id="header">
			<div class="header_con">
				<a href="${s.base}/phone/home?memberId=${member.id}"><span></span></a>
                <div class="top_tit">
					流量充值
				</div>
			</div>
		</header>
		<div id="content_div">
			<div class="pay_02">
				<input type="hidden" id="memberId" value="${member.id}">
				<p class="border_bottom">昵称<span><input type="text" disabled id="name"  value="${member.nickName}" style="width: 100%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: right;" placeholder="请输入姓名" /></span></p>
			</div>
			<div class="pay_02">
				<p class="border_bottom">手机号<span><input type="text" disabled id="phone" value="${member.phone}" style="width: 100%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: right;" placeholder="请输入手机号" /></span></p>
			</div>
			<div class="pay_02">
				<p class="border_bottom">已有流量<span><input type="text" disabled id="alreadyFlowNum" value="${member.flowNum}" style="width: 100%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: right;" placeholder="请输入省" /></span></p>
			</div>
			<div class="pay_02">
				<p class="border_bottom">充值流量<span><input type="text" id="flowNum" style="width: 100%;height: 0.8rem;line-height: 0.8rem;border: 0px; text-align: right;" placeholder="请输入充值流量" /></span></p>
			</div>
		</div>
		<div class="pay_04 margin_top_1"><a class="ui-btn" style="color: #FFF;" href="javascript:void(0)" onclick="flowNum()">立即充值</a></div>

		<!--底部-->
		<!--底部结束-->
        <script type="text/javascript" src="${s.base}/mobile/js/jquery-1.7.2.min.js"></script>
		<script src="${s.base}/mobile/js/jquery-weui.min.js"></script>
		<script type="text/javascript" src="${s.base}/mobile/js/common.js"></script>
		<script type="text/javascript" src="${s.base}/js/layer/layer.js"></script>
		<script type="text/javascript" src="${s.base}/mobile/js/passwordBox.min.js"></script>
		<script type="text/javascript" src="${s.base}/js/base/commont.js"></script>

			<script>
                /***************支付方法****************/
                function payMethod(memberId,payPassword,flowNum){
                    var flowId = '${flowDesc.id}';
                    if(payPassword == null || payPassword == ""){
                        layer.alert("您必须先设置支付密码！");
                        return false;
                    }
                    /**
                     * init传入参数依次是：正确密码(传空时不对比输入是否正确),密码键盘背景，标题，副标题
                     * */
                    PwdBox.init(payPassword,'/mobile/images/pwd_keyboardw.png','请输入支付密码','安全支付环境，请放心使用！');
                    /**
                     *res格式：{status:'true或false',password:'用户输入的密码'}
                     *
                     */
                    PwdBox.show(function(res){
                        var password=res.password;
                        if(res.status){
                            $.post("/flowRecord/updateOrAddEntity",{
                                memberId : memberId,
                                // activityId : activityId,
                                flowId : flowId,
                                flowCount : flowNum
                            },function(result){
                                if (result.returnInfo.state == '1'){
                                    showLayerAlertNoRefre("购买成功！请联系管理领取奖励！");
                                } else {
                                    showLayerAlertNoReload(result.returnInfo.errorMsg);
                                }
                            },"json");
                        }else{
                            //重置输入
                            layer.alert('密码不正确，请重新输入！');
                            //关闭并重置密码输入
                            PwdBox.reset();
                            resultNum(num);

                        }
                    });
                };
				/****************************************/

				function flowNum() {
					var memberId = '${member.id}';
                    var payPassword = '${member.payPassword}';
					var alreadyFlowNum = $("#alreadyFlowNum").val();
					var flowNum = $("#flowNum").val();
					// alert(parseInt(alreadyFlowNum) -parseInt(flowNum));
					if ((parseInt(alreadyFlowNum) - parseInt(flowNum)) > 0){
                        layer.alert("您的余额不足，不能提现流量！");
                        return false;
					}
                    payMethod(memberId,payPassword,flowNum);
                }
			</script>
	</body>

</html>